<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        var _name = "数据值";
        var data = {};
        Object.defineProperty(data, "name", {
            get:function(){
                console.log("data.name被调用-get");
                return _name;
            },
            set:function(newValue){
                console.log("data.name被赋值-set", newValue);
                _name = newValue;
            }
        });
        
        var _value = "";
        var obj = {};
        Object.defineProperty(obj, "value", {
            get () {
                return _value;
            },
            set(nv) {
                _value = nv;
                h1Dom = document.getElementById("h1Dom");
                h1Dom.textContent = nv;
            }
        })
        function changeValue(nv){
            _value = nv;
            // obj.value = nv;
        }
    </script>
</head>
<body>
    <h1 id="h1Dom"></h1>
    <input type="text" id="inputDom" oninput="changeValue(this.value)">
</body>
</html>